package com.beyond.parse;


import com.alibaba.druid.util.JdbcConstants;

import java.util.*;

public class XmlParse {

    public static void main(String[] args) {
        XmlSQLParse parse = new XmlSQLParse("C:\\Users\\beyond\\Desktop\\UserMapper.xml", JdbcConstants.MYSQL);
        parse.parseXml();
        Map<String, Set<String>> parameterMap = parse.getParameterMap();

        for (Map.Entry entry : parameterMap.entrySet()) {
            Set<String> set = (Set<String>) entry.getValue();

            Map<String, String> columnMap = new HashMap();
            for (String value: set) {
                columnMap.put(value, "varchar");
            }

            List<String> sqlList = new ArrayList<String>();
            try {
                sqlList = parse.getSQLList((String) entry.getKey(), columnMap);
            } catch (Exception e) {
                e.printStackTrace();
            }

            for (String sql : sqlList) {
                System.out.println(entry.getKey()+ ":[" + sql + "]");
            }
        }
    }


}
